(function(window){
	function Geci(path){
		return new Geci.prototype.init(path)
	}
	Geci.prototype={
		constructor:Geci,
		init:function(path){
			this.path=path
		},
		time_zhou:[],
		ci_ku:[],
		index:-1,
		index_compare_min:0,
		index_compare_max:1,
		index_containter:-1,
		loadgeci:function(back){
			this_geci=this
			$.ajax({
				url:this_geci.path,
				dateType:"text",
				success:function(data){
					 this_geci.splice(data)
					back()
				},
				error:function(reason){
					console.log(reason);
				}
			})
		},
		splice:function(data){
			var this_geci=this
			this.time_zhou=[]
			this.ci_ku=[]
			var row=data.split("\n")
			var timeReg=/\[([0-9]{2})\:([0-9]{2}\.[0-9]{2,})\]/
			$.each(row,function(index,ele){
				var ci=ele.split("]")[1]
				// console.log(ele)
				if(ci.length<=1){
					return true
				}
				this_geci.ci_ku.push(ci)
				var time=timeReg.exec(ele)
				if(time==null){
					return true
				}
				time=parseFloat((parseInt(time[1]*60)+parseFloat(time[2])).toFixed(2))
				this_geci.time_zhou.push(time)
			})
		},
		index_mate:function(time){
			if(time>=this.time_zhou[this.index_compare_min]&&time<=this.time_zhou[this.index_compare_max]){
				//正常的时间流逝
				this.index=this.index_compare_min
				this.index_compare_min++
				this.index_compare_max++
				this.index_containter=this.index
				return this.index
			}
			else if(time>this.time_zhou[this.index_compare_max]){
				//进度条时间被拖动至当前歌词坐标之后
				while(time>this.time_zhou[this.index_compare_max]){
					if(this.index_compare_max>=this.time_zhou.length){	//防止越界
						break
					}
					this.index_compare_max++
				}
				this.index_compare_min=this.index_compare_max-1
				this.index=this.index_compare_min
				this.index_containter=this.index
				return this.index
			}
			else{
				//进度条时间被拖动至当前歌词坐标之前
				while(time<this.time_zhou[this.index_compare_min]){
					if(this.index_compare_min<=0){
						break
					}
					this.index_compare_min--
				}
				console.log('min',this.index_compare_min);
				this.index_compare_max=this.index_compare_min+1
				this.index=this.index_compare_min
				this.index_containter=this.index
				return this.index
			}
		}
	}
	Geci.prototype.init.prototype=Geci.prototype
	window.Geci=Geci;
})(window);